<template>
  <div id="app">
    <div class="title">购物车案例</div>
    <div class="ShoppingList">
    <ShoppingItem v-for="(items) in itemList" :key="items.id" :datas="items"></ShoppingItem>
    </div>
    <Balance></Balance>
  </div>
</template>

<script>
import ShoppingItem from '@/components/item.vue'
import Balance from '@/components/balance.vue'
import { mapActions, mapState } from 'vuex'
export default {
  name: 'App',
  components: {
    ShoppingItem,
    Balance
  },
  created () {
    this.getItemList()
  },
  methods: {
    ...mapActions('itemInfo', ['getItemList'])
  },
  computed: {
    ...mapState('itemInfo', ['itemList'])
  }
}
</script>

<style lang="less">
body{
  margin: 0;
  background-color: whitesmoke;
}
#app {
  position: relative;
  display: block;
  width: 500px;
  height: 600px;
  margin: auto;
  margin-top: 20px;
  color: #2c3e50;
  text-align: center;
}
.title{
  background-color: #37AB80;
  color: white;
  width: 100%;
  height: 3em;
  line-height: 3em;
}
.ShoppingList{
  max-height: 400px;
  overflow: scroll;
  scrollbar-width: none;
}
.values{
  color: #C83433;
}
</style>
